Skip to content

make sure virtual machine params exist#12771

Open
DaanHoogland wants to merge 2 commits intoapache:4.22from
shapeblue:ghi11941-restoreWithPassword
Open

make sure virtual machine params exist#12771
DaanHoogland wants to merge 2 commits intoapache:4.22from
shapeblue:ghi11941-restoreWithPassword

Conversation

@DaanHoogland
Copy link
Contributor

@DaanHoogland DaanHoogland commented Mar 9, 2026

Description

This PR...

Fixes: #11941

Types of changes

  • Breaking change (fix or feature that would cause existing functionality to change)
  • New feature (non-breaking change which adds functionality)
  • Bug fix (non-breaking change which fixes an issue)
  • Enhancement (improves an existing feature and functionality)
  • Cleanup (Code refactoring and cleanup, that may add test cases)
  • Build/CI
  • Test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • Major
  • Minor

Bug Severity

  • BLOCKER
  • Critical
  • Major
  • Minor
  • Trivial

Screenshots (if appropriate):

How Has This Been Tested?

How did you try to break this feature and the system with this change?

@DaanHoogland DaanHoogland changed the base branch from main to 4.22 March 9, 2026 11:50
@DaanHoogland DaanHoogland added this to the 4.22.1 milestone Mar 9, 2026
@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 17.61%. Comparing base (5caf6cd) to head (242b743).
⚠️ Report is 17 commits behind head on 4.22.

Files with missing lines Patch % Lines
.../src/main/java/com/cloud/vm/UserVmManagerImpl.java 0.00% 6 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##               4.22   #12771   +/-   ##
=========================================
  Coverage     17.60%   17.61%           
- Complexity    15659    15665    +6     
=========================================
  Files          5917     5917           
  Lines        531394   531395    +1     
  Branches      64970    64967    -3     
=========================================
+ Hits          93575    93595   +20     
+ Misses       427269   427245   -24     
- Partials      10550    10555    +5     
Flag Coverage Δ
uitests 3.70% <ø> (-0.01%) ⬇️
unittests 18.68% <0.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to ensure the VM start/deploy parameter map is always initialized (non-null) during UserVmManagerImpl.startVirtualMachine, addressing failures when parameters are expected to exist (notably in password-enabled template flows, per #11941).

Changes:

  • Initialize params as a new HashMap<> instead of null when starting a VM.
Comments suppressed due to low confidence (2)

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:5803

  • Initializing params as an empty HashMap changes behavior: createParameterInParameterMap only copies parameterMap (i.e., additionalParams) into params when params == null. With this change, when vm.isUpdateParameters() is true, params will end up containing only the explicitly added entries (e.g., VmPassword), and will no longer include other additionalParams such as UEFI boot options (UefiFlag/BootType/BootMode) or ConsiderLastHost, which are expected downstream (e.g., logged/used during start). Consider initializing params as a copy of additionalParams (or adjusting createParameterInParameterMap to always merge parameterMap) so all start parameters are preserved while still guaranteeing params is non-null.
        // Set parameters
        Map<VirtualMachineProfile.Param, Object> params = new HashMap<>();
        if (vm.isUpdateParameters()) {
            _vmDao.loadDetails(vm);

            String password = getCurrentVmPasswordOrDefineNewPassword(String.valueOf(additionalParams.getOrDefault(VirtualMachineProfile.Param.VmPassword, "")), vm, template);

server/src/main/java/com/cloud/vm/UserVmManagerImpl.java:5803

  • This change alters how the start parameter map is built; please add/adjust a unit test to assert the returned params is non-null and still includes entries from additionalParams (e.g., UEFI/boot mode params or ConsiderLastHost) when vm.isUpdateParameters() is true, to prevent regressions in the start/deploy flow.
        // Set parameters
        Map<VirtualMachineProfile.Param, Object> params = new HashMap<>();
        if (vm.isUpdateParameters()) {
            _vmDao.loadDetails(vm);

            String password = getCurrentVmPasswordOrDefineNewPassword(String.valueOf(additionalParams.getOrDefault(VirtualMachineProfile.Param.VmPassword, "")), vm, template);


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Member

@weizhouapache weizhouapache left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code lgtm

@DaanHoogland
Copy link
Contributor Author

@blueorangutan package

@blueorangutan
Copy link

@DaanHoogland a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✖️ debian ✔️ suse15. SL-JID 17046

@weizhouapache
Copy link
Member

@blueorangutan package

@blueorangutan
Copy link

@weizhouapache a [SL] Jenkins job has been kicked to build packages. It will be bundled with KVM, XenServer and VMware SystemVM templates. I'll keep you posted as I make progress.

@blueorangutan
Copy link

Packaging result [SF]: ✔️ el8 ✔️ el9 ✔️ el10 ✔️ debian ✔️ suse15. SL-JID 17051

@weizhouapache
Copy link
Member

@blueorangutan test

@blueorangutan
Copy link

@weizhouapache a [SL] Trillian-Jenkins test job (ol8 mgmt + kvm-ol8) has been kicked to run smoke tests

@blueorangutan
Copy link

[SF] Trillian test result (tid-15583)
Environment: kvm-ol8 (x2), zone: Advanced Networking with Mgmt server ol8
Total time taken: 51642 seconds
Marvin logs: https://github.com/blueorangutan/acs-prs/releases/download/trillian/pr12771-t15583-kvm-ol8.zip
Smoke tests completed. 146 look OK, 3 have errors, 0 did not run
Only failed and skipped tests results shown below:

Test Result Time (s) Test File
ContextSuite context=TestListIdsParams>:teardown Error 1.11 test_list_ids_parameter.py
test_01_snapshot_root_disk Error 3.73 test_snapshots.py
test_02_list_snapshots_with_removed_data_store Error 46.37 test_snapshots.py
test_02_list_snapshots_with_removed_data_store Error 46.38 test_snapshots.py
ContextSuite context=TestSnapshotStandaloneBackup>:teardown Error 27.24 test_snapshots.py
test_01_snapshot_usage Error 25.61 test_usage.py
test_01_vpn_usage Error 1.08 test_usage.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create Instance from Backup taken from a password enabled template not working

5 participants